/**
 * @file e5_t2_q4.c
 * @date 2022-03-09
 * 
 * @copyright Copyright (c) 2022 cnzyx MIT Licence
 * 
 */

#include<stdio.h>
#include<stdlib.h>
#define MAX 100

int fun(int lim,int aa[MAX]){
    int cnt=0,cnt_array=0;
    for(int i=2;i<=lim;i++){
        for(int j=2;j<i;j++){
            if(i%j==0){
                cnt++;
            }
        }
        if(!cnt){
            aa[cnt_array]=i;
            cnt_array++;
        }
        cnt=0;
    }
    return cnt_array;
}

int main(int argc, char const *argv[])
{
    //UTF-8
    system("chcp 65001");

    int array[MAX],len,in_num;
    printf("请输入临界值lim：");
    scanf("%d",&in_num);
    len=fun(in_num,array);
    printf("小于%d的素数有：",in_num);
    for(int i=0;i<len;i++){
        printf("%d ",array[i]);
    }
    printf("\n");
    //Pause console
    system("pause");
    return 0;
}
